import * as Cesium from 'cesium';
import waterLayer from './water/waterLayer'
import LayerManage from './LayerManage/layermanage'
import waterPlayer from './WaterPlay/waterplay'
import toolBar from './ToolsBar/toolbar'
import areaNav from "./areaNav/areaNav.js"
import DrawWorker from "./DrawWorker/DrawWorker.js"
import editModel from './ModelControl/editModel'
// import {createModel} from "./ModelControl/addmodel"
import River1Point from '../river1'
import floods from '../flood.js'

import miniMap from "./miniMap/miniMap"
import withDrawMgr from "./withdraw/withdrawmgr"


export const initwaterPlayer = function(viewer){
    var myPlayer = new waterPlayer(viewer)
    myPlayer.initData(floods)
}
export const inittoolBar = function(viewer){
    var mytoolBar = new toolBar(viewer)
}
export const initareaNav =  function(viewer){
    return new areaNav(viewer)
}
export const initDrawWorker =  function(viewer){
    return new DrawWorker(viewer)
}
export const initMiniMap =  function(viewer){
    var myMiniMap = new miniMap(viewer)
}

export const initWithDrawMgr =  function(viewer){
    var mywithDrawMgr = new withDrawMgr(viewer)
}

export const initlayerManage= function(viewer){
    // 图层管理
    var data =[
        {
            title: '南瓯江',
            children: [{
                title: '区间',
                children: [{
                        id:"001001001",
                        title: '一级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "一级电站",
                        position:{
                            x: 102.316914,
                            y: 20.14649,
                            z: 284,
                            heading: 303,
                            pitch: 0,
                            roll:0,
                            scale: 0.2,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {    
                        id:"001001002",
                        title: '二级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "一级电站",
                        scale: 1,
                        position:{
                            x: 102.450094,
                            y: 20.389012,
                            z: 300,
                            heading: 278,
                            pitch: 0,
                            scale: 0.1,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10,
                            scale: 0.2,
                        }
                    },
                    {
                        id:"001001003",
                        title: '三级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "一级电站",
                        scale: 1,
                        position:{
                            x: 102.658591,
                            y: 20.815629,
                            z: 333,
                            heading: 257,
                            pitch: 0,
                            scale: 0.1,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10,
                            scale: 0.2,
                        }
                    },
                    {
                        id:"001001004",
                        title: '四级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "四级电站",
                        scale: 0.5,
                        position:{
                            x: 102.501602,
                            y: 21.095077,
                            z: 373,
                            heading: 328,
                            pitch: 0,
                            scale: 0.2,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001001005",
                        title: '五级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "五级电站",
                        scale: 1,
                        position:{
                            x: 102.344331,
                            y: 21.411582,
                            z: 414,
                            heading: 297,
                            pitch: 0,
                            scale: 0.2,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001001006",
                        title: '六级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "五级电站",
                        scale: 0.2,
                        position:{
                            x: 102.195479,
                            y: 21.7714,
                            z: 453,
                            heading: 326,
                            pitch: 0,
                            scale: 0.1,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001001007",
                        title: '七级电站', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/powerplant/tileset.json",
                        popup: "五级电站",
                        scale: 1,
                        position:{
                            x: 102.262845,
                            y: 22.07058,
                            z: 507,
                            heading: 278,
                            pitch: 0,
                            scale: 0.1,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    }
                ]
            },
            {
                title: '建筑',
                children: [{
                        title: '南欧江房屋', //三级菜单
                        type:"gltf",
                        id:"001002001",
                        url:"http://localhost:8081/Apps/data/fangwu.gltf",
                        popup: "这是欧江房屋",
                        scale: 1,
                        position:{
                            x: 102.603348,
                            y: 20.576760,
                            z: 370,
                            heading: 109,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001002002",
                        title: '房屋', //三级菜单
                        type:"dtiles",
                        url:"http://localhost:8081/Apps/data/buildings/tileset.json",
                        popup: "房屋",
                        scale: 1,
                        position:{
                            x: 102.609348,
                            y: 20.572760,
                            z: 312, //342
                            heading: 5,
                            pitch: 3,
                            roll: 339,
                            scale: 1,
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    }
                ]
            },
            {
                title: '水坝',
                children: [{
                        title: '一级', //三级菜单
                        type:"gltf",
                        layer:"大巴模型"
                    },
                    {
                        title: '二级', //三级菜单
                        type:"gltf",
                        layer:"大巴模型"
                    }
                ]
            },
            {
                title: '水文站',
                children: [{
                        id:"001004001",
                        title: 'Luang Prabang', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "Luang Prabang水文站",
                        scale: 0.002,
                        position:{
                            x: 102.219858,
                            y: 19.940545,
                            z: 0,
                            heading: 150,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004002",
                        title: '孟威水文站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "孟威水文站",
                        scale: 0.002,
                        position:{
                            x: 102.673333,
                            y: 20.712792,
                            z: 0,
                            heading: 90,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004003",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.001,
                        position:{
                            x: 102.5308,
                            y: 20.603,
                            z: 320,
                            heading: 18,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004004",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.002,
                        position:{
                            x: 102.342747,
                            y: 20.368730,
                            z: 317,
                            heading: 189,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004005",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.004,
                        position:{
                            x: 102.442912027,
                            y: 20.3826905429,
                            z: 301,
                            heading: 110,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004006",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.004,
                        position:{
                            x: 102.673357478,
                            y: 20.712726494,
                            z: 320,
                            heading: 96,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004007",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.002,
                        position:{
                            x: 102.488012,
                            y: 21.136126,
                            z: 354,
                            heading: 269,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004008",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.001,
                        position:{
                            x: 102.444803,
                            y: 21.045912,
                            z: 370,
                            heading: 10,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004009",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.001,
                        position:{
                            x: 102.188919,
                            y: 21.563280,
                            z: 475,
                            heading: 158,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004010",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.002,
                        position:{
                            x: 102.196699,
                            y: 21.743908,
                            z: 434,
                            heading: 168,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004011",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.002,
                        position:{
                            x: 102.2608,
                            y: 22.061291,
                            z: 558.3,
                            heading: 110,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                    {
                        id:"001004012",
                        title: '雨量、水位及流量巡测站', //三级菜单
                        type:"gltf",
                        url:"http://localhost:8081/Apps/data/flood/station.gltf",
                        popup: "雨量、水位及流量巡测站",
                        scale: 0.002,
                        position:{
                            x: 102.03004,
                            y: 22.06011,
                            z: 600,
                            heading: 326,
                            pitch: 0
                        },
                        center: {
                            y: 20.561904,
                            x: 102.60824,
                            z: 1922.86,
                            heading: 12.2,
                            pitch: -54.4,
                            roll: 10
                        }
                    },
                ]
            }]
        },
        {
            title: '湘江',
            children: [{
                title: '区间',
                children: [
                ]
            },
            {
                title: '水坝',
                children: [ {
                    id: "002002001",
                    type: "gltf",
                    title: "长沙枢纽",
                    url: "http://localhost:8081/Apps/data/flood/shuiba_mobener_large.gltf",
                   popup: "这是长沙枢纽",
                    scale: 5,
                    position: {
                        x: 112.828085,
                        y: 28.389,
                       z: 47,
                        heading: -30
                    },
                    center: {
                        y: 28.371721,
                        x: 112.835442,
                       z: 1439.42,
                        heading: 348.1,
                        pitch: -36.1,
                        roll: 359.7
                    }
                },
                {
                    id: "002002002",
                    type: "gltf",
                    title: "湘潭站",
                    url: "http://localhost:8081/Apps/data/flood/shuiba_mobener_large.gltf",
                   popup: "这是湘潭站",
                    scale: 3,
                    position: {
                        x: 112.931068,
                        y: 27.864308,
                       z: 54.9,
                        heading: 60
                    },
                    center: {
                        y: 27.858921,
                        x: 112.915331,
                       z: 921.76,
                        heading: 74,
                        pitch: -27.4,
                        roll: 359.6
                    }
                },
                {
                    id: "002002003",
                    type: "gltf",
                    title: "株洲枢纽",
                    tooltip: "这是株洲枢纽",
                    url: "http://localhost:8081/Apps/data/flood/shuiba_mobener_large.gltf",
                    scale: 3.5,
                    position: {
                        x: 113.10341,
                        y: 27.64285,
                       z: 46.2,
                        heading: 0
                    },
                    center: {
                        y: 27.632186,
                        x: 113.103797,
                       z: 1074.03,
                        heading: 5.7,
                        pitch: -45.4,
                        roll: 359.9
                    }
                }
                ]
            },
            {
                title: '水文站',
                children: [
                ]
            },
            {
                title: '城市建筑',
                children: [
                ]
            }]
        }
    ]
    var layerM = new LayerManage(viewer)
    layerM.initData(data) 
    var water = new waterLayer(River1Point)
    water.addTo(viewer.scene)
    return layerM
}